package com.ktgj.customer.service.impl;

import java.util.ArrayList;
import java.util.List;

import com.ktgj.common.core.annotation.Excel;
import com.ktgj.customer.domain.vo.ItinerarySummaryVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktgj.customer.mapper.TravelItinerarySummaryMapper;
import com.ktgj.customer.domain.TravelItinerarySummary;
import com.ktgj.customer.service.ITravelItinerarySummaryService;

/**
 * 行程概要Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-13
 */
@Service
public class TravelItinerarySummaryServiceImpl implements ITravelItinerarySummaryService 
{
    @Autowired
    private TravelItinerarySummaryMapper travelItinerarySummaryMapper;

    /**
     * 查询行程概要
     * 
     * @param travelItinerarySummaryId 行程概要ID
     * @return 行程概要
     */
    @Override
    public TravelItinerarySummary selectTravelItinerarySummaryById(Long travelItinerarySummaryId)
    {
        return travelItinerarySummaryMapper.selectTravelItinerarySummaryById(travelItinerarySummaryId);
    }

    /**
     * 查询行程概要列表
     * 
     * @param travelItinerarySummary 行程概要
     * @return 行程概要
     */
    @Override
    public List<TravelItinerarySummary> selectTravelItinerarySummaryList(TravelItinerarySummary travelItinerarySummary)
    {
        return travelItinerarySummaryMapper.selectTravelItinerarySummaryList(travelItinerarySummary);
    }

    /**
     * 新增行程概要
     * 
     * @param travelItinerarySummary 行程概要
     * @return 结果
     */
    @Override
    public int insertTravelItinerarySummary(TravelItinerarySummary travelItinerarySummary)
    {
        return travelItinerarySummaryMapper.insertTravelItinerarySummary(travelItinerarySummary);
    }

    /**
     * 修改行程概要
     * 
     * @param travelItinerarySummary 行程概要
     * @return 结果
     */
    @Override
    public int updateTravelItinerarySummary(TravelItinerarySummary travelItinerarySummary)
    {
        return travelItinerarySummaryMapper.updateTravelItinerarySummary(travelItinerarySummary);
    }

    /**
     * 批量删除行程概要
     * 
     * @param travelItinerarySummaryIds 需要删除的行程概要ID
     * @return 结果
     */
    @Override
    public int deleteTravelItinerarySummaryByIds(Long[] travelItinerarySummaryIds)
    {
        return travelItinerarySummaryMapper.deleteTravelItinerarySummaryByIds(travelItinerarySummaryIds);
    }

    /**
     * 删除行程概要信息
     * 
     * @param travelItinerarySummaryId 行程概要ID
     * @return 结果
     */
    @Override
    public int deleteTravelItinerarySummaryById(Long travelItinerarySummaryId)
    {
        return travelItinerarySummaryMapper.deleteTravelItinerarySummaryById(travelItinerarySummaryId);
    }

    /**
     * 查询指定旅游产品的行程概要详细信息
     * */
    @Override
    public List<ItinerarySummaryVo> itinerarySummaryVoList(Long groupId) throws Exception {
        if (groupId != null && groupId != 0){
            List<TravelItinerarySummary> travelItinerarySummaries = travelItinerarySummaryMapper.selectTravelItinerarySummary(groupId);
            if (travelItinerarySummaries != null){
                List<ItinerarySummaryVo> itinerarySummaryVoList = new ArrayList<>();
                for (TravelItinerarySummary travelItinerarySummary : travelItinerarySummaries) {
                    ItinerarySummaryVo itinerarySummaryVo = new ItinerarySummaryVo();
                    itinerarySummaryVo.setTravelItinerarySummaryName(travelItinerarySummary.getTravelItinerarySummaryName());
                    itinerarySummaryVo.setTravelItinerarySummaryDesc(travelItinerarySummary.getTravelItinerarySummaryDesc());
                    itinerarySummaryVoList.add(itinerarySummaryVo);
                }
                return itinerarySummaryVoList;
            }
            else {
                throw new Exception("未查到数据");
            }
        }
        else {
            throw new Exception("缺少必要参数");
        }
    }
}
